
<?php 
//session_start();		//启用session支持
//if(isset($_SESSION['unc'])){		//获取登录的版主名称
$tur=0;
if (($_FILES["file"]["type"] == "image/gif")
		|| ($_FILES["file"]["type"] == "image/jpeg")
		|| ($_FILES["file"]["type"] == "image/png")
		|| ($_FILES["file"]["type"] == "image/x-png")
		|| ($_FILES["file"]["type"] == "image/pjpeg")) {
			if($_FILES["file"]["size"] < 200000){
				
		
				if ($_FILES["file"]["error"] > 0) {
					echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
				} else {
					
					$tur=1;
				}
			}else
			{
				echo "<script>alert('图片不能大于200KB'); history.back();</script>";
			}

}
else
{
	echo "<script>alert('查看你的图片格式是否正确'); history.back();</script>";
}
if ($tur==1) {
	include_once("../conn/all.php");		//包含数据库文件
	//$usernc=$_SESSION['unc'];		//调用注册时提交的用户名称
	 session_start();
		$user=$_SESSION["unc"];
	if ($_POST['Submit']=='上传') {
			$filename="img/".$user."logo".$_FILES["file"]["name"];
			$data=array("logo"=>$filename);
			sql("u", "face", $data, 'where user='.$usernc);
			move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" .$filename);
		echo "<script>alert('上传成功'); history.back();</script>";
			}
		}else{
			
		echo "<script>alert('请先录入信息'); history.back();</script>";
		}
		
		if ($_POST['Submit']=='提交') {
		$sql=mysql_query("select * from info where name='".$usernc."'",$conn);
		$res=mysql_fetch_assoc($sql);
		$info=mysql_num_rows($sql);
		 mysql_free_result($sql);
		if($info==1){
			if ($res['img']!='') {
				$imagename=$res['img'].'|'.$filename;
				mysql_query("update info set img='$imagename'where name='".$usernc."'",$conn);
				move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" .$filename);
				echo "<script>alert('上传成功'); history.back();</script>";
			}else{
				$imagename='|'.$filename;
			mysql_query("update info set img='$imagename'where name='".$usernc."'",$conn);
			move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" .$filename);
			echo "<script>alert('上传成功'); history.back();</script>";
			}
		}else{
			echo "<script>alert('请先录入信息'); history.back();</script>";
		}
		}
	
	
			
//	}else{
//		echo "<script>alert('请先登录'); window.location.href='make.php?mod=login';</script>";
//	}